//
// Created by xili on 2024/8/21 15:46.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    vector <vector<int>> findMatrix(vector<int> &nums) {
        //统计每个数字出现的次数
        //保存出现次数的最大值
        int row = 0;
        unordered_map<int, int> ump;
        for (auto &item: nums) {
            ump[item]++;
            row = max(row, ump[item]);
        }
        vector <vector<int>> ans;
        for (int i = 0; i < row; i++) {
            vector<int> v;
            for (auto &item: ump) {
                if (item.second > 0) {
                    v.push_back(item.first);
                    item.second--;
                }
            }
            ans.push_back(v);
        }
        return ans;
    }
};